package com.homework0425.race;

public class Rabbit extends  Thread {

    private int distance = 10;



    @Override
    public void run() {

        long starttime = System.currentTimeMillis();
        while (distance>0){

            try{
                Thread.sleep(3);
                distance--;
                System.out.println("兔子跑了1KM剩余"+distance+"km");
                if(distance==3){
                    System.out.println("兔子在睡觉zzz");
                    Thread.sleep(150);
                    System.out.println("兔子睡醒了");
                }

            }catch (Exception e){
                System.out.println(e);

            }
        }
        long endtime = System.currentTimeMillis();

        System.out.println("兔子完成比赛！" +"用时："+(endtime-starttime)+"分钟");

    }
}
